package com.citas.shared;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Encriptar {
	
	private static String toHexadecimal(byte[] digest){
        String hash = "";
        for(byte aux : digest) {
            int b = aux & 0xff;
            if (Integer.toHexString(b).length() == 1) hash += "0";
	            hash += Integer.toHexString(b);
		        }
        return hash;
    }

	public static String encriptar(String message){
        byte[] digest = null;
        byte[] buffer = message.getBytes();
      
        MessageDigest messageDigest = null;
		try {
			messageDigest = MessageDigest.getInstance("MD5");
		} catch (NoSuchAlgorithmException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        messageDigest.reset();
        messageDigest.update(buffer);
        digest = messageDigest.digest();
        
	    return toHexadecimal(digest);
    }
	public static void main (String [ ] args) 
    { 
        System.out.println ("'"+encriptar("edson")+"'"); 
     } 
	
}



